﻿<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             x:Class="FBToolkit.Sample.Silverlight.App"
             >

    <Application.Resources>

        <DataTemplate x:Key="StreamStory_CommentPartDT">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="40"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Image Width="35" Height="35" Stretch="Fill"  Source="{Binding pic_square}" />

                <StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Center" Margin="5,5,0,0">
                    <StackPanel Orientation="Horizontal">
                        <HyperlinkButton Content="{Binding poster_name}" Foreground="#FF3b5998"
                                         NavigateUri="{Binding poster_profile.url}" TargetName="_blank"
                                         FontSize="11"  FontFamily="Lucida Grande"  />
                        <TextBlock Margin="0,2,0,0" HorizontalAlignment="Left" FontSize="9" Foreground="LightSlateGray" FontFamily="Lucida Grande" Text="{Binding UpdateTime}" />
                    </StackPanel>

                    <TextBlock TextWrapping="Wrap" FontFamily="Lucida Grande" HorizontalAlignment="Left" Text="{Binding comment.Text}"/>

                </StackPanel>
            </Grid>
        </DataTemplate>

        <Style x:Key="ListBoxItemStyle1" TargetType="ListBoxItem">
            <Setter Property="Foreground" Value="#FF000000" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid x:Name="RootElement" ShowGridLines="True">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="70"></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>

                            <Image Width="50" Height="50" Stretch="Fill" ImageFailed="Image_ImageFailed"  Source="{Binding profile.Picture}" VerticalAlignment="Top" Margin="20,10,0,0"/>

                            <StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Left" Margin="10,10,0,0">
                                <HyperlinkButton Content="{Binding profile.Name}" NavigateUri="{Binding profile.Url}" TargetName="_blank" 
                                         FontWeight="Bold"  FontSize="13" FontFamily="Lucida Grande" Foreground="#FF3b5998"/>
                                <TextBlock TextWrapping="Wrap" Foreground="Black" FontFamily="Lucida Grande" HorizontalAlignment="Left" Text="{Binding stream_post.Message}"/>

                                <StackPanel Orientation="Horizontal">
                                    <TextBlock HorizontalAlignment="Left" FontSize="11" FontFamily="Lucida Grande" Foreground="LightSlateGray" Text="{Binding UpdateTime}"/>
                                    <TextBlock HorizontalAlignment="Left" FontSize="11" FontFamily="Lucida Grande" Foreground="#FF3b5998" Text="  Comment "/>
                                    <TextBlock HorizontalAlignment="Left" FontSize="11" FontFamily="Lucida Grande" Foreground="#FF3b5998" Text="  Like "/>
                                </StackPanel>

                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                                        <ColumnDefinition></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <ListBox ItemsSource="{Binding stream_post.Attachment.Media}" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Background="Transparent" >
                                        <ListBox.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <StackPanel Orientation="Horizontal"/>
                                            </ItemsPanelTemplate>
                                        </ListBox.ItemsPanel>
                                        <ListBox.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <Image Width="100" Height="90" Source="{Binding Path=Source}" ImageFailed="Image_ImageFailed"></Image>
                                                </StackPanel>
                                            </DataTemplate>
                                        </ListBox.ItemTemplate>
                                    </ListBox>
                                    <StackPanel Orientation="Vertical" Grid.Column="1">
                                        <TextBlock TextWrapping="Wrap" FontWeight="Bold" FontSize="12" FontFamily="Lucida Grande" HorizontalAlignment="Left" Text="{Binding stream_post.Attachment.Name}"/>
                                        <TextBlock TextWrapping="Wrap" FontFamily="Lucida Grande" HorizontalAlignment="Left" Text="{Binding stream_post.Attachment.Description}"/>
                                    </StackPanel>
                                </Grid>

                                <ListBox  x:Name="CommentList"
                                      BorderThickness="0"
                                      ItemsSource="{Binding comments}"  
                                      ItemTemplate="{StaticResource StreamStory_CommentPartDT}"
                                      Margin="0,2,0,0"
                                      Background="Transparent" 
                                     >
                                </ListBox >

                            </StackPanel>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="StreamListBoxStyle" TargetType="ListBox">
            <Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItemStyle1}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBox">
                        <Grid x:Name="LayoutRoot">
                            <Border Padding="5" CornerRadius="5">
                                <ScrollViewer>
                                    <ItemsPresenter />
                                </ScrollViewer>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


    </Application.Resources>
    
</Application>
